import request from '@/utils/request'
import { camelCaseObject } from '@/libs/object'

const AUTH_PREFIX_V1 = `/api/v1/rds`

export function getRdsClusterList(params) {
  return request.get(`${AUTH_PREFIX_V1}/clusters`, { params }).then(res => camelCaseObject(res))
}

export function getRdsClusterListByPage(params) {
  return request.get(`${AUTH_PREFIX_V1}/clusters/page`, { params }).then(res => camelCaseObject(res))
}

export function getRdsCluster(clusterId) {
  return request.get(`${AUTH_PREFIX_V1}/clusters/${clusterId}`).then(res => camelCaseObject(res))
}

export function createRdsCluster(params) {
  return request.post(`${AUTH_PREFIX_V1}/clusters`, params).then(res => camelCaseObject(res))
}

export function updateRdsCluster(clusterId, params) {
  return request.put(`${AUTH_PREFIX_V1}/clusters/${clusterId}`, params).then(res => camelCaseObject(res))
}

export function deleteRdsCluster(clusterId) {
  return request.delete(`${AUTH_PREFIX_V1}/clusters/${clusterId}`).then(res => camelCaseObject(res))
}
